/**
 * jQuery EasyUI 自定义orgbox扩展选择控件
 * TiddlerCJ 
 */
<select class="easyui-combotreegrid" name="orgNo" style="width:260px;" data-options="label:'组织结构:',panelWidth:300,panelWidth:450,required:true,
	           	idField: 'orgNo', 
	           	missingMessage:'必填项',
				treeField: 'orgName',
				value:'${SESSION_USER.user.orgNo}',
				sortName:'orgOrder',
				onSelect:function(row){
					$('input[name=department]').val(row.orgName);	    
				},
				sortOrder:'asc',
	            url:'/console/com.fs.base.pojo.Org/list', 
	            queryParams:{isTreeGrid:'true', treeId:'id', treePid:'parentId' },
	            columns:[[    
	                {field:'orgName',			width:190,	title:'组织名称' }
		         	,{field:'orgType',			width:70,	title:'分类' }
		         	,{field:'orgNo',				width:100,	title:'组织编码' }
		         	,{field:'orgLeaderName',	width:70,	title:'负责人'}
	            ]]"></select>

(function($){
    $.parser.plugins.push("orgbox");
    $.fn.autoCode = function (options, param) { 
        if (typeof options == "string") { return $.fn.textbox.apply(this, arguments);}
        options = options || {};
        return this.each(function(){
            var jq = $(this);
            var opts = $.extend({}, $.fn.textbox.parseOptions(this), options);
            /*异步拉取自动生成代码*/
            function aotoCode(myopts){
            	if(myopts.prefix){
            		var url = "/console/"+ myopts.prefix +"/autoCode" ;
            		$.getJSON(url, { suffix: myopts.suffix,timestamp: (myopts.timestamp ||'')  } ,function(json){
            			if(json && json.flag){
            				jq.textbox('setText', json.data.code);
            				jq.textbox('setValue', json.data.code);
            			}
            		});
            	}
            }
            var myopts = $.extend(true, {
            	buttonText:'刷新',
            	buttonIcon:'icon-reload',
            	editable: false,
            	onClickButton:function(){
            		aotoCode(myopts);
            	}
            }, opts);
            $.fn.textbox.call(jq, myopts);
            setTimeout(function(){
            	aotoCode(myopts);
            	/*输入框隐藏属性*/
            	var hidden = jq.attr("type")==='hidden';
            	if(hidden){
            		jq.next("span").hide();
            	}
            },100);
        });
    };
})(jQuery);